﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;
using System.Threading;

namespace Business.AutheAuthor
{
    public class BasicStuff
    {
        public static void DoBasicStuff()
        {

            //get windows identity
            WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();

            //get windows principal 
            WindowsPrincipal windowsPrincipal = new WindowsPrincipal(windowsIdentity);
            Console.WriteLine(windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator));


            //specify that WindowsPrincipal should be used
            AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

            //get as an object
            WindowsPrincipal currentPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;
            
        }
    }
}
